<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<table cellspacing="0" border="0" width="995">
	<tr>
		<td width="995" class="title_manager_product">Quản lý sản phẩm</td>
	</tr>
	<tr>
		<td height="90">
			<table border="0" cellpadding="0" cellspacing="0" width="995">
				<tr>
					<td align="center">
						<table border="0" cellpadding="0" cellspacing="0">
							<tr>
								<td align="center"><a href="index.php?admin=productAdmin&do=formaddcategory"><img src="images/CreateNews.gif" width="48" height="47" border="0" /></a></td>
							</tr>
							<tr>
								<td align="center" class="title_new_add"><a href="index.php?admin=productAdmin&do=formaddcategory">Tạo danh mục sản phẩm</a></td>
							</tr>
						</table>
						
					</td>
					
					<td align="center">
						<table border="0" cellpadding="0" cellspacing="0">
							<tr>
								<td align="center"><a href="index.php?admin=productAdmin&do=formaddgroup"><img src="images/CreateCategory.gif" width="51" height="48" border="0" /></a></td>
							</tr>
							<tr>
								<td align="center" class="title_new_add"><a href="index.php?admin=productAdmin&do=formaddgroup">Tạo nhóm sản phẩm</a></td>
							</tr>
						</table>
						
					</td>
					
					<td align="center">
						<table border="0" cellpadding="0" cellspacing="0">
							<tr>
								<td align="center"><a href="index.php?admin=productAdmin&do=formaddproduct"><img src="images/CreateCategory.gif" width="51" height="48" border="0" /></a></td>
							</tr>
							<tr>
								<td align="center" class="title_new_add"><a href="index.php?admin=productAdmin&do=formaddproduct">Thêm mới sản phẩm</a></td>
							</tr>
						</table>
						
					</td>
					
				</tr>
			</table>
		</td>	
	</tr>
</table>
<table cellspacing="0" border="0" width="995">
	<tr>
		<td width="200" valign="top">					
			<?php
				include("menuleftcategory.php");
			?>
		</td>	
		<td width="795" valign="top">
			<form action="index.php?admin=productAdmin&do=formaddgroup" method="post" enctype="multipart/form-data">
				<table cellspacing="0" border="0" width="790">
					<tr>
						
						<td width="790" class="title_manager_cate">Tạo nhóm sản phẩm</td>
					
					</tr>
				</table>
				<table class="reference" cellspacing="0" border="1" width="100%">  
					<tr>
						<td colspan="2" align="center">
							<?php
								$groupName=$_POST['groupName'];
								$cateID=$_POST['cateID'];
								
								$target="../upload/groupCate/";
								$link=$target.$_FILES['groupImage']['name'];
								move_uploaded_file($_FILES['groupImage']['tmp_name'],$link);
								
								if(isset($_POST['submit'])){
									if($groupName==''){
										echo "<span class=\"error_message\">Bạn phải nhập vào tên nhóm sản phẩm.</span>";
									}
								
									if($groupName!=''){
										$query="INSERT INTO groupcategories(cateID,groupName,groupImage) VALUES ('$cateID','$groupName','$link')";
										mysql_query($query);
										echo "Thêm nhóm sản phẩm thành công.";
										echo "<script>window.location='index.php?admin=productAdmin&do=listgroup&id=$cateID'</script>";
									}
								}	
							?>	
						</td>
					</tr>	 	
					<tr>
						<td width="200">Tên nhóm sản phẩm</td>
						<td width="400">
							<input type="text" name="groupName" size="30" /><font color="#FF0000"> * </font>
						</td>
					</tr>
					<tr>
						<td>Danh mục sản phẩm:</td>
						<td>
							<select name="cateID">
								<?php					
								$query = "select * from categories";
								$result = mysql_query($query);
								while($row = mysql_fetch_array($result)){?>
									<option value="<?php echo $row['id']?>"><?php echo $row['cateName'];?></option>	
								<?php
								}
								?>
							 </select>   
						</td>
					</tr>
					
				   <tr>
						<td></td>
						<td>
							<input type="submit" name="submit" value="Tạo nhóm sản phẩm mới" />
							<input type="reset" name="reset" value="Nhập lại" />
							<input type="button" name="Cancel" value="Cancel" onclick="window.location = 'index.php?admin=productAdmin&do=listproduct' " /> 
						<td>
				   </tr>
				</table>
			</form>
		</td>
	</tr>	
</table>
</body>
</html>
